home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1984 September / 1984-09.d64 / disk tricks 3 (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  1KB  |  29 lines

  1. 100 sys65517:ifpeek(781)=22thenmt$="":goto2999
  2. 110 mt$=""
  3. 2998 rem end: rem program 3, unscratch files
  4. 2999 printmt$
  5. 3000 input "[147]which sector";s$: s=val(s$): if s<0 or s>19 then 3000
  6. 3010 print "what is the first byte":print"of the file you wish"
  7. 3011 print"to unscratch?"
  8. 3020 input bp$: bp=val(bp$): rem input file target byte for unscratch
  9. 3030 bs=(bp=2)+(bp=34)+(bp=66)+(bp=98)+(bp=130)+(bp=162)+(bp=194)+(bp=226)
  10. 3035 ifbs<>-1then3020:rem reject invalid input
  11. 3040 print "select file type:"
  12. 3050 print "  1. sequential"
  13. 3060 print "  2. program"
  14. 3070 print "  3. user"
  15. 3080 print "  4. relative"
  16. 3090 print "which one?"
  17. 3100 get a$: if a$="" then 3100
  18. 3110 a=val(a$): if a<1 or a>4 then 3100: rem reject invalid choice
  19. 3120 b=a+128: rem set input byte to match dos file codes
  20. 3130 open 15,8,15,"i": rem open command channel to disk
  21. 3140 open8,8,8,"#": rem open direct access channel to disk
  22. 3150 print#15, "u1:"8;0;18;s: rem load sector containing file to be unscratched
  23. 3160 print#15, "b-p:"8;bp: rem set buffer pointer to target address
  24. 3170 print#8, chr$(b);: rem change target file code in channel 8 buffer
  25. 3180 print#15, "u2:"8;0;18;s: rem return changed contents to target sector
  26. 3190 close 8: rem close direct access channel
  27. 3200 close 15: rem close command channel
  28. 3210 rem goto 100: rem restart display t&s program when first rem removed
  29.